//
//  MovingVC.m
//  K-Music
//
//  Created by CHUN on 15/12/27.
//  Copyright © 2015年 CHUN. All rights reserved.
//

#import "MovingVC.h"
#import "user_mode.h"

#import "InteractionCell.h"
#import "inter_L.h"

#import "YYplayerVC.h"
#import "MyDataService.h"

#import "A_Music.h"
#import "NSObject+EBPropertyListing.h"
#import "UIImageView+WebCache.h"

#import "MyAllText.h"
#import "Personal_VC.h"

#import "musicing_mode.h"

#import "WHScrollAndPageView.h"

@interface MovingVC ()<UITableViewDataSource,UITableViewDelegate,NSURLConnectionDataDelegate,WHcrollViewViewDelegate>{
    
    UITableView*mytabview;
    
    NSMutableArray*interData;
    
    WHScrollAndPageView *_whView;
    
}

@property(nonatomic,strong)NSMutableArray*allMusicData;

@end

@implementation MovingVC


-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=YES;
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=NO;
}

- (void)loadView
{
    [super loadView];
    
    //通知
    [[NSNotificationCenter defaultCenter] addObserver: self selector:
     @selector(music_play) name: @"music_play" object:nil];
    
    [self Gift_rankData];
    
    [self get_fans];
    
    [self get_Bag];
    
    [self get_About];
    
//    [self get_KROOM];
//    
//    [self get_KROOM_history];
//    
//    [self get_MyROOM];
    
//    [self seven_token];
    
//    [self get_Singer_category];
    
    [self get_all_music];
    [self get_QUYU];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=RGB(241, 241, 241);
    interData=[NSMutableArray array];
    NSLog(@"%@",[FileStorage NSUserDefault_getObjectForKey:access_token]);
    [MyAllText useIt].access_token=[FileStorage NSUserDefault_getObjectForKey:access_token];
    [self creatUI];
    
    [self gainTheRecordsData];
    //[self gainTheAllFriendsData];
    
}

-(void)creatUI{
    
    UIView*MyView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 100)];
    MyView.backgroundColor=RGB(244, 219, 182);
    [self.view addSubview:MyView];
    
    UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(10, 30, 60,60)];
    image.layer.cornerRadius= image.frame.size.width/2;
    image.layer.masksToBounds = YES;
    [image setUserInteractionEnabled:YES];
    
    NSString * imageurl = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:user_image]];
    
    if ([imageurl isEqualToString:@"001"]) {
        image.image=[UIImage imageNamed:@"icon_person"];
    }
    else
    {
        [image sd_setImageWithURL:[NSURL URLWithString:imageurl]];
    }
    
    [MyView addSubview:image];
    UITapGestureRecognizer * PersonalTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Personal)];
    [image addGestureRecognizer:PersonalTap];
    
    UILabel *name=[[UILabel alloc]initWithFrame:CGRectMake(image.frame.size.width+image.frame.origin.x+20, 30, WIDTH/2, 30)];
    
    if (imageurl.length == 0 ){
        name.text = @"CHUN";
    }
    else
    {
        name.text= [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:nickName]];
        name.font = [UIFont systemFontOfSize:15.0f];
    }
    
    [MyView addSubview:name];
    
    UILabel*info=[[UILabel alloc]initWithFrame:CGRectMake(image.frame.size.width+image.frame.origin.x+20, CGRectGetMaxY(name.frame), WIDTH/2, 30)];
    
    if (imageurl.length == 0 ) {
        info.text = @"K号：10000";
    }else
    {
        info.text = [NSString stringWithFormat:@"K号：%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];
        info.font = [UIFont systemFontOfSize:15.0f];
    }
    
    [MyView addSubview:info];
    
    UIImageView* VIP =[[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/2, 50,25,15)];
    VIP.image = [UIImage imageNamed:@"vip_one"];
    //    [MyView addSubview:VIP];
    
    UIImageView* star_one =[[UIImageView alloc]initWithFrame:CGRectMake(WIDTH-100, 30,30,25)];
    star_one.image = [UIImage imageNamed:@"star_one"];
    //    [MyView addSubview:star_one];
    
    UIImageView* star_two =[[UIImageView alloc]initWithFrame:CGRectMake(WIDTH-100, 70,30,25)];
    star_two.image = [UIImage imageNamed:@"star_two"];
    //    [MyView addSubview:star_two];
    
    UIButton*miucs=[UIButton buttonWithType:UIButtonTypeCustom];
    [miucs setBackgroundImage:[UIImage imageNamed:@"play"] forState:UIControlStateNormal];
    [miucs addTarget:self action:@selector(play_play) forControlEvents:UIControlEventTouchUpInside];
    
    miucs.frame=CGRectMake(WIDTH-60, 50, 40, 20);
    [MyView addSubview: miucs];

    _whView = [[WHScrollAndPageView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(MyView.frame), WIDTH, 80)];
    
    
    mytabview =[[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_whView.frame)+5, WIDTH, HEIGHT-CGRectGetMaxY(_whView.frame)-5-49)];
    mytabview.delegate=self;
    mytabview.dataSource=self;
    [self.view addSubview:mytabview];
    
    
    //加载更多
//    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(headRefresh)];
//    mytabview.footer = footer;
    
}


-(void)topAdTap:(UITapGestureRecognizer *)sender
{
    UITapGestureRecognizer * tap = (UITapGestureRecognizer *)sender;
    UIImageView *viewg = (UIImageView *) tap.view;
    NSInteger ined = viewg.tag - 68402;
    NSLog(@"%ld",ined);
    
}

- (void)Gift_rank
{
    Gift_Rank_Mode * mode =[[Gift_Rank_Mode alloc]init];
    
    NSMutableArray * imageArr = [NSMutableArray array];
    
    for (int i = 0; i < _Gift_Rank_Datas.count; i++)
    {
        mode = _Gift_Rank_Datas[i];
        
        UIView*TextView=[[UIView alloc]initWithFrame:CGRectMake(i*WIDTH,0, WIDTH, 80)];
        
        TextView.backgroundColor=[UIColor whiteColor];
        
        UIImageView*Teximage=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 60 , 60)];
        Teximage.layer.masksToBounds = YES;
        Teximage.layer.cornerRadius= 30.0f;
        [Teximage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",mode.fromUserAvatar]]];
        [TextView addSubview:Teximage];
        
        UILabel *Texname=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(Teximage.frame)+20, 10, WIDTH/2, 30)];
        NSString * A_TO_B = [NSString stringWithFormat:@"%@ 送给 %@",mode.fromUserId,mode.toUserId];
        
        Texname.textColor = [UIColor orangeColor];
        
        Texname.text= A_TO_B;
        Texname.font = [UIFont systemFontOfSize:15];
        [TextView addSubview:Texname];
        
        UILabel*Texinfo=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(Teximage.frame)+20, 40, WIDTH/2, 30)];
        NSString * Num_giftName = [NSString stringWithFormat:@"%@ 个 %@",mode.giftNumber,mode.giftName];
        Texinfo.text= Num_giftName;
        Texinfo.font = [UIFont systemFontOfSize:15];
        Texinfo.textColor = [UIColor orangeColor];
        [TextView addSubview:Texinfo];
        
        TextView.userInteractionEnabled = YES;
        TextView.tag = i+68402;
        
        
        UIImageView* Gift_Icoin=[[UIImageView alloc]initWithFrame:CGRectMake(WIDTH-80, 10, 60 , 60)];
        Gift_Icoin.layer.masksToBounds = YES;
        Gift_Icoin.layer.cornerRadius= 30.0f;
        [Gift_Icoin sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",mode.giftIcoin]]];
        [TextView addSubview:Gift_Icoin];
        
        UITapGestureRecognizer *topAdTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(topAdTap:)];
        [TextView addGestureRecognizer:topAdTap];
        
        [imageArr addObject:TextView];
        
    }
    
    [_whView setImageViewAry:imageArr];
    
    //开启自动翻页
    [_whView shouldAutoShow:YES];
    
    //遵守协议
    _whView.delegate = self;
    
    [self.view addSubview:_whView];
}

#pragma mark--获取全部作品
-(void)gainTheRecordsData{
    
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
//    if ([User_information conversion].page_all_records == 0) {
//        [User_information conversion].page_all_records = 1;
//    }
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/records?page=1&size=40&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"获取全部作品------:%@",dic);
        
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [A_Music objectArrayWithKeyValuesArray:arr];
        _allMusicData = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].musicData = _allMusicData;
        
        [mytabview reloadData];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
        
        NSLog(@"%@",error);
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];

    }];
}

#pragma mark----获取全部朋友的全部作品
-(void)gainTheAllFriendsData{
    
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/records/friends/all?page=1&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"获取全部朋友的全部作品------:%@",dic);
        if ( [dic[@"errorCode"]intValue]== 1404 )
        {
            _allMusicData=nil;
            [mytabview reloadData];
            
        }
        else
        {
            NSLog(@"resultCode:%@",dic[@"resultCode"]);
            
            _allMusicData=[NSMutableArray array];
            
            NSArray * arr = dic[@"body"][@"content"];
            NSArray * Datas = [A_Music objectArrayWithKeyValuesArray:arr];
            _allMusicData = [NSMutableArray arrayWithArray:Datas];

            [mytabview reloadData];
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error){
        
        NSLog(@"%@",error);
        _allMusicData=nil;
        [mytabview reloadData];
        [MBProgressHUD showErrorWithStatus:@"获取好友列表失败" toView:self.view];
        
    }];
    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}


- (void)Personal
{
    NSLog(@"个人信息");
    Personal_VC * ppp =[[Personal_VC alloc]init];
    [self.navigationController pushViewController:ppp animated:YES];
}

- (void)play_play
{
    NSLog(@"play");
//    [MBProgressHUD showErrorWithStatus:@"播放器" toView:self.view];
    [self music_play];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _allMusicData.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 126;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 40;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString*inf=@"InteractionCell";
    
    InteractionCell*cell=[tableView  dequeueReusableCellWithIdentifier:inf];
    if (cell == nil) {
        
        cell = [[[NSBundle mainBundle]loadNibNamed:@"InteractionCell" owner:self options:nil ] firstObject];
        
    }
    A_Music* data=[[A_Music alloc]init];
    
    data = _allMusicData [indexPath.row];
    
    //4 用户名 + 3 图标
    NSMutableAttributedString * attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",data.nickName]];
    
    //(1)VIP icon
    // 添加表情
    NSTextAttachment *vip = [[NSTextAttachment alloc] init];
    // 设置图片大小
    vip.bounds = CGRectMake(2, 0, 25, 12.5);
    // 表情图片
    vip.image = [UIImage imageNamed:@"vip_one"];
    
    // 创建带有图片的富文本
    NSAttributedString * vip_Icon = [NSAttributedString attributedStringWithAttachment:vip];
    
    [attri appendAttributedString:vip_Icon];
    
    //(2)fortune
    NSTextAttachment * fortune = [[NSTextAttachment alloc]init];

    fortune.bounds = CGRectMake(2, -5, 25, 25);

    [cell.Fortune_image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",data.fortuneLevelIcon]]];

    fortune.image = cell.Fortune_image.image ;

    NSAttributedString * fortuneLevel_Icon = [NSAttributedString attributedStringWithAttachment:fortune];

    [attri appendAttributedString:fortuneLevel_Icon];

    //(3)singer
    NSTextAttachment * singer = [[NSTextAttachment alloc]init];

    singer.bounds = CGRectMake(2, -5, 25, 25);

    [cell.Song_image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",data.singerLevelIcon]]];

    singer.image = cell.Song_image.image ;

    NSAttributedString * singerLevel_Icon = [NSAttributedString attributedStringWithAttachment:singer];

    [attri appendAttributedString:singerLevel_Icon];
    
    // 用label的attributedText属性来使用富文本
    cell.Itt_name.attributedText = attri;
    
    cell.info_text.text=[NSString stringWithFormat:@"%@",data.name];
    cell.infoter_text.text=[NSString stringWithFormat:@"%@",data.descriptionD];
    
    //CHUN  收听  礼物  转发 评论
    cell.text1.text=[NSString stringWithFormat:@"%@",data.totalPlay];
    cell.text2.text=[NSString stringWithFormat:@"%@",data.totalGift];
    cell.text3.text=[NSString stringWithFormat:@"%@",data.totalShare];
    cell.text4.text=[NSString stringWithFormat:@"%@",data.totalComment];
    
    [cell.image_photo sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",data.avatar]]];
    
    cell.image_photo.layer.cornerRadius= cell.image_photo.width/2 ;
    cell.image_photo.layer.masksToBounds = YES;
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    YYplayerVC*yy=[[YYplayerVC alloc]init];
    yy.hidesBottomBarWhenPushed = YES;
    
    yy.musicData= _allMusicData[indexPath.row];
    
    [yy setTracks:[Track remoteTracks]];
    [self.navigationController pushViewController:yy animated:NO];
    
    [tableView deselectRowAtIndexPath:tableView.indexPathForSelectedRow animated:YES];
}


-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH,40)];
    headerview.backgroundColor = RGB(241, 241, 241);
    
    //    mytabview.tableHeaderView=headerview;
    
    NSArray*textData;
    
    textData=[NSArray arrayWithObjects:@"全部作品",@"好友作品",nil];
    
    for (int i=0; i<2; i++) {
        UIButton*topBtn=[[UIButton alloc]initWithFrame:CGRectMake(i*WIDTH/2, 1,WIDTH/2-1, 40-2)];
        topBtn.backgroundColor=[UIColor whiteColor];
        [topBtn setTitle:textData[i] forState:UIControlStateNormal];
        [topBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [topBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
        
        topBtn.userInteractionEnabled = YES;
        topBtn.tag=i+100;
        [topBtn addTarget:self action:@selector(TopButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [headerview addSubview:topBtn];
    }
    return headerview;
}

-(void)TopButtonClick:(UIButton*)btn
{
    NSLog(@"hehehehe,点击");
    
    _allMusicData=nil;
//    _allMusicData=[NSMutableArray array];
    
    if (btn.tag==101) {
        [self gainTheAllFriendsData];
    }else{
        [self gainTheRecordsData];
    }
    
}

#pragma mark --  跳转播放器    --
- (void)music_play
{
    NSLog(@"DDDD");
    
    if ([User_information conversion].musicData.count != 0) {
        
        YYplayerVC * yy = [[YYplayerVC alloc]init];
        
        yy.hidesBottomBarWhenPushed = YES;
        
        yy.musicData = [User_information conversion].musicData[0];
        
        [yy setTracks:[Track remoteTracks]];
        
        [self.navigationController pushViewController:yy animated:NO];
        
    }
    else
    {
        [MBProgressHUD showErrorWithStatus:@"加载中..." toView:self.view];
        
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 异步拿数据 -
- (void)Gift_rankData
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/gift_rank"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"GET Gift_rank --> %@", dic);
        _Gift_Rank_Datas = [NSMutableArray array];
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [Gift_Rank_Mode objectArrayWithKeyValuesArray:arr];
        _Gift_Rank_Datas = [NSMutableArray arrayWithArray:Datas];
        [self Gift_rank];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD showErrorWithStatus:@"数据获取失败-about-" toView:self.view];
        
    }];
    
}
#pragma mark----- 所有歌曲
- (void)get_all_music
{
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/song?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> %@", dic);
        
        if ([dic[@"errorCode"]intValue] != 1404 )
        {
            NSArray*content=dic[@"body"][@"content"];
            
            _musicingData = [NSMutableArray array];
            
            for (NSDictionary * Data in content) {
                musicing_mode * mode =[[musicing_mode alloc]init];
                
                mode.accompanyUrl =Data[@"accompanyUrl"];
                mode.coverImage =Data[@"coverImage"];
                mode.createdBy =Data[@"createdBy"];
                mode.createdDate =Data[@"createdDate"];
                mode.descriptiond =Data[@"description"];
                mode.heat =Data[@"heat"];
                mode.aid =Data[@"id"];
                
                mode.lastModifiedBy =Data[@"lastModifiedBy"];
                mode.lastModifiedDate =Data[@"lastModifiedDate"];
                
                mode.lyric =Data[@"lyric"];
                mode.name =Data[@"name"];
                mode.singerName =Data[@"singerName"];
                mode.size =Data[@"size"];
          
                mode.url =Data[@"url"];
                
                [mode fixedString];
                
                [_musicingData addObject:mode];
                
            }
        }else{
            
            _musicingData = nil;
            
        }
        [User_information conversion].SING_Data = [_musicingData copy];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        
        [MBProgressHUD showErrorWithStatus:@"获取数据失败" toView:self.view];
        
    }];
}

#pragma mark----- 粉丝
- (void)get_fans
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * userId = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/fans/user_id/%@?page=0&size=20&sort=createdDate,DESC",userId];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> fans%@", dic);
        _fansDatas = [NSMutableArray array];
        NSArray * arr = dic[@"body"];
        NSArray * Datas = [fans_Model objectArrayWithKeyValuesArray:arr];
        _fansDatas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].fans_Data = [ _fansDatas copy];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
    }];
}

#pragma mark----- 背包
- (void)get_Bag
{
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * userId = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/gifts/bought/user_id/%@?page=0&size=20&sort=createdDate,DESC",userId];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        _BagDatas = [NSMutableArray array];
        
        NSArray * body = dic[@"body"];
        
        if (body.count != 0 ) {
            
            NSArray * bagDatas = [Bag_model objectArrayWithKeyValuesArray:body];
            _BagDatas = [NSMutableArray arrayWithArray:bagDatas];
        }
        
        [User_information conversion].Bag_person_Data = _BagDatas;
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
        
    }];
}
#pragma mark----- 关于K歌房
- (void)get_About
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/settings/key/ABOUT?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"GET about --> %@", dic);
        [User_information conversion].about_K = [dic objectForKey:@"body"];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD showErrorWithStatus:@"数据获取失败-about-" toView:self.view];
        
    }];
    
   NSString * about_H =[NSString stringWithFormat:@"/api/settings/key/ABOUT_MEMBER?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL_H = [MyBaseUrl stringByAppendingString:about_H];
    
    [manager GET:intactURL_H parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"GET about --> %@", dic);
        [User_information conversion].about_H = [dic objectForKey:@"body"];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD showErrorWithStatus:@"数据获取失败-about-" toView:self.view];
        
    }];
    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
 
}
/*
#pragma mark----- 所有房间
- (void)get_KROOM
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];

    NSString*infoStr11=[NSString stringWithFormat:@"/api/rooms?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> kroom%@", dic);
        _KROOMDatas = [NSMutableArray array];
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [K_Mode objectArrayWithKeyValuesArray:arr];
        _KROOMDatas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].KROOM_Data = [ _KROOMDatas copy];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
    }];
    
}

#pragma mark----- 历史访问
- (void)get_KROOM_history
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * userId = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/rooms/history/user_id/%@?page=0&size=20&sort=createdDate,DESC",userId];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> kroom_history%@", dic);
        _KROOMDatas = [NSMutableArray array];
        NSArray * arr = dic[@"body"];
        NSArray * Datas = [K_Mode objectArrayWithKeyValuesArray:arr];
        _KROOMDatas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].KROOM_history_Data = [ _KROOMDatas copy];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
    }];
}

- (void)get_MyROOM
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * userId = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];

    NSString*infoStr11=[NSString stringWithFormat:@"/api/rooms/user_id/%@?page=0&size=20&sort=createdDate,DESC",userId];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> MineROOM-%@", dic);
        _KROOMDatas = [NSMutableArray array];
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [K_Mode objectArrayWithKeyValuesArray:arr];
        _KROOMDatas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].MYROOM_Data = [ _KROOMDatas copy];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
    }];
}
 */

#pragma mark----- 7牛  token
- (void)seven_token
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/qiniu/get-upload-token?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> 7牛 - %@", dic);
        
        NSDictionary * body = dic[@"body"];
        
        [User_information conversion].domainName_seven = [body objectForKey:@"domainName"];
        
        [User_information conversion].key_seven = [body objectForKey:@"key"];
        
        [User_information conversion].token_seven = [body objectForKey:@"token"];
        

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
       
        [MBProgressHUD showErrorWithStatus:@"7牛数据获取失败" toView:self.view];
        
    }];
    
     [MBProgressHUD hideHUDForView:self.view animated:YES];

}

#pragma mark----- 歌手分类 -- 歌曲分类
- (void)get_Singer_category
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/singer_category?page=0&size=20&sort=createdDate,DESC"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"GET Singer_category --> %@", dic);
        _Singer_category_Datas = [NSMutableArray array];
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [Singer_category_mode objectArrayWithKeyValuesArray:arr];
        _Singer_category_Datas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].Singer_category_Data = [ _Singer_category_Datas copy];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD showErrorWithStatus:@"数据获取失败-Singer_category-" toView:self.view];
        
    }];
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    
}

#pragma mark-----城市列表
- (void)get_QUYU
{
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * userId = [NSString stringWithFormat:@"%@",[FileStorage NSUserDefault_getObjectForKey:User_id]];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/admin_area"];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"%@",dic);
        
        NSArray * arr = dic[@"body"][@"content"];
        NSArray * Datas = [Admin_area_mode objectArrayWithKeyValuesArray:arr];
        [User_information conversion].admin_area = [NSMutableArray arrayWithArray:Datas];
        
        NSLog(@"%@",arr);
        
        [User_information conversion].adminAreaCode = [arr[0] objectForKey:@"adminAreaCode"];
        [User_information conversion].area_city = [arr[0] objectForKey:@"city"];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
        
    }];
}





@end
